package com.ruoyi.web.controller.ic;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ic.pojo.domain.IcGeneralH;
import com.ruoyi.ic.service.IIcGeneralHService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 出库单表头Controller
 * 
 * @author ruoyi
 * @date 2024-11-25
 */
@RestController
@RequestMapping("/ruoyi-ic/ic")
public class IcGeneralHController extends BaseController
{
    @Autowired
    private IIcGeneralHService icGeneralHService;

    /**
     * 查询出库单表头列表
     */
    @PreAuthorize("@ss.hasPermi('ruoyi-ic:ic:list')")
    @GetMapping("/list")
    public TableDataInfo list(IcGeneralH icGeneralH)
    {
        startPage();
        List<IcGeneralH> list = icGeneralHService.selectIcGeneralHList(icGeneralH);
        return getDataTable(list);
    }

    /**
     * 导出出库单表头列表
     */
    @PreAuthorize("@ss.hasPermi('ruoyi-ic:ic:export')")
    @Log(title = "出库单表头", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IcGeneralH icGeneralH)
    {
        List<IcGeneralH> list = icGeneralHService.selectIcGeneralHList(icGeneralH);
        ExcelUtil<IcGeneralH> util = new ExcelUtil<IcGeneralH>(IcGeneralH.class);
        util.exportExcel(response, list, "出库单表头数据");
    }

    /**
     * 获取出库单表头详细信息
     */
    @PreAuthorize("@ss.hasPermi('ruoyi-ic:ic:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(icGeneralHService.selectIcGeneralHById(id));
    }

    /**
     * 新增出库单表头
     */
    @PreAuthorize("@ss.hasPermi('ruoyi-ic:ic:add')")
    @Log(title = "出库单表头", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IcGeneralH icGeneralH)
    {
        return toAjax(icGeneralHService.insertIcGeneralH(icGeneralH));
    }

    /**
     * 修改出库单表头
     */
    @PreAuthorize("@ss.hasPermi('ruoyi-ic:ic:edit')")
    @Log(title = "出库单表头", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IcGeneralH icGeneralH)
    {
        return toAjax(icGeneralHService.updateIcGeneralH(icGeneralH));
    }

    /**
     * 删除出库单表头
     */
    @PreAuthorize("@ss.hasPermi('ruoyi-ic:ic:remove')")
    @Log(title = "出库单表头", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(icGeneralHService.deleteIcGeneralHByIds(ids));
    }
}
